package com.IOFileTest;

import org.junit.Test;

import java.io.FileWriter;
import java.io.IOException;

public class FileWrite_ {
    public static void main(String[] args) {

    }

    @Test
    public void writefile(){
        String filePath = "d:\\story.txt";
        FileWriter fileWriter = null;
        char chars[] = {'a','b','c'};
        try{
            fileWriter = new FileWriter(filePath,true);
//            fileWriter.write("hell,goy");
//            fileWriter.write(chars);
//            fileWriter.write("zhahangsan",0,6);
//            fileWriter.write(chars,0,2);
            fileWriter.write('d');
            System.out.println();
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try{
                fileWriter.close();
            }catch (IOException e){
                e.printStackTrace();
            }
        }
        System.out.println("程序结束");
    }
}
